package entity.lianxi.demo01;

import entity.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.rmi.server.RemoteObjectInvocationHandler;

/*
* 通过反射获取构造方法*/
public class Maintest01 {
    public static void main(String[] args) throws Exception {
        //第一种
        /*Class<?> yin = Class.forName("entity.Student");
        Constructor<?> constructor = yin.getConstructor();
        Object obj = constructor.newInstance();
        if (obj instanceof Student ){
            Student stu = new Student();
            stu.setName("王五");
        }*/


       /* //第二种
        Class<Student> List = Student.class;
        Constructor<Student> constructor = List.getConstructor();
        Student stu = constructor.newInstance();
        stu.sayHello("超六");*/

        //第三种
        Student stu = new Student();
        Class<?> clazz = stu.getClass();
        Constructor<?> constructor = clazz.getConstructor();

        Object obj = constructor.newInstance();
        if (obj instanceof Student) {
            Student s = (Student) obj;
            // 5.调用方法
            s.sayHello("王八");
        }

        //第四种
        Class<Integer> clazz01 = Integer.TYPE;
        Class<Integer> clazz02 = int.class;
        System.out.println(clazz01==clazz02);

    }
}
